import BaseItemView from "../../../cfw/mvc/BaseItemView";
import ModuleManager from "../../../cfw/module/ModuleManager";
import { ResType } from "../../../cfw/res/ResInterface";
import ResItem from "../../../cfw/res/ResItem";
import ItemController from "../../item/ItemController";
import BaseItemModel from "../../../cfw/mvc/BaseItemModel";

const { ccclass, property } = cc._decorator;

@ccclass
export default class ClotheItemView extends BaseItemView {


    @property(cc.Sprite)
    icon: cc.Sprite = null;

    protected model: BaseItemModel;
    protected controller: ItemController;

    refresh() {
        // cc.log("ClotheItemView mdoel  ",this.model.getIcon())
        ModuleManager.getLoader().loadRes(this.model.getIcon(), ResType.SpriteFrame, (err, res: ResItem) => {
            if (err || !cc.isValid(this.node)) {
                return;
            }
            this.icon.spriteFrame = res.getRes()
            this.icon.node.scale = this.model.getScale()
        })
    }

    onButtonClick() {
        console.log("点击")

        this.controller.onButtonIconClick(this.model)
    }

    // update (dt) {}
}
